package example.com.zcq.mymj.activity;

import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;


import com.allenliu.versionchecklib.callback.OnCancelListener;
import com.allenliu.versionchecklib.core.http.HttpRequestMethod;
import com.allenliu.versionchecklib.v2.AllenVersionChecker;
import com.allenliu.versionchecklib.v2.builder.DownloadBuilder;
import com.allenliu.versionchecklib.v2.builder.NotificationBuilder;
import com.allenliu.versionchecklib.v2.builder.UIData;
import com.allenliu.versionchecklib.v2.callback.ForceUpdateListener;
import com.allenliu.versionchecklib.v2.callback.RequestVersionListener;

import example.com.zcq.mymj.R;
import example.com.zcq.mymj.util.UpdateManager;

import static com.allenliu.versionchecklib.v2.ui.VersionService.builder;

public class TestActivity extends AppCompatActivity {

    private UpdateManager mUpdateManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        updateApk();
        findViewById(R.id.btn_test).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //这里来检测版本是否需要更新
                //                mUpdateManager = new UpdateManager(TestActivity.this);
                //                mUpdateManager.showNoticeDialog(1.3,1.2);

            }
        });
    }

    private void updateApk() {

        builder = AllenVersionChecker
                .getInstance()
                .downloadOnly(
                        UIData.create().setTitle("hahah").setContent("m=neiosng")

                                .setDownloadUrl("http://rongxin.ixiangni.cn/ixiangni/测试安装包.apk")
                );

        builder.setForceRedownload(true);
        builder.executeMission(this);


    }


}
